package com.example.demo.dao;

import com.example.demo.model.Userinfo;
import com.example.demo.model.vo.ArticleinfoVO;
import com.example.demo.model.vo.UserinfoVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {

    @Select("select * from userinfo")
    List<Userinfo> getUserAll();

    @Update("update userinfo set state = '0' where username = #{username}")
    int updateClose(@Param("username")String username);

    @Update("update userinfo set state = '1' where username = #{username}")
    int updateOpen(@Param("username")String username);

    @Select("select * from waitinfo")
    List<ArticleinfoVO> getBookAll();

    @Select("select * from waitinfo where title = #{title} and user = #{user}")
    ArticleinfoVO getApply(ArticleinfoVO articleinfoVO);

    @Insert("insert into articleinfo(title,content,uid,updateTime) values (#{title},#{content},#{uid},#{updatetime})")
    int add(ArticleinfoVO articleinfoVO);

    @Delete("delete from waitinfo where title = #{title} and user = #{user}")
    int del(ArticleinfoVO articleinfoVO);

    @Select("select * from proveinfo")
    List<UserinfoVO> getWriterAll();

    @Select("select * from proveinfo where username = #{username} and prove = #{prove}")
    UserinfoVO getWriterApply(UserinfoVO userinfoVO);

    @Delete("delete from proveinfo where username = #{username} and prove = #{prove}")
    int delWriterApply(UserinfoVO userinfoVO);

    @Insert("insert into userinfo(username, password, type, updatetime) values (#{username}, #{password}, #{type}, #{updatetime})")
    int addWriter(UserinfoVO userinfoVO);

}
